#初始化一个玩家信息状态以函数的形式表现
player_infors = " "
class State(object):
  
  def __init__(self,HP = 10,Lv = 1,Atk = 1):
    self.HP = HP
    self.Lv = Lv
    self.Atk = Atk


  def SaveState(self):
    player_infors = "HP:" + self.HP + "Lv:" + self.Lv + "Atk:" + self.Atk
    f = open("save.data","w")
    f.write(str((player_infors)))
    f.close()
    print("保存成功！")
    print("=====================")

   #加载数据函数
   #如果没有save.data文件，啥都不做，就等存档创建
  def LoadState(self):
    global player_infors
    try:    
        f = open("save.data")
        player_infors = eval(f.read())
        f.close()
        return player_infors
    except Exception:
        pass
